package net.bolue.web.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.bolue.sysmng.exception.BolueException;
import net.bolue.web.report.RepConstants;
import net.bolue.web.util.RequestUtil;

/**
 * 弹出字典
 * @author Administrator
 *
 */
public class PopSetDicAction extends AbstractAction{

	@Override
	public ActionResult perform(HttpServletRequest request,
			HttpServletResponse response) throws BolueException {
		String subSys = RequestUtil.getParamValue(request, RepConstants.REP_SUBSYS_KEY);
		String dicKind = RequestUtil.getParamValue(request, "dicKind");
		if ((subSys == null) || (dicKind == null) ){
			throw new BolueException(5, "request参数错,subSys,dicKind必须提供!");
		}
		String _valDicCol = RequestUtil.getParamValue(request, "valDicCol");
		String _dicGrpID = RequestUtil.getParamValue(request, "dicGrpID");
		Integer valDicCol = 0;
		Integer dicGrpID = 0;
		if (_valDicCol != null){
			valDicCol = Integer.parseInt(_valDicCol);
		}
		if (_dicGrpID != null){
			dicGrpID = Integer.parseInt(_dicGrpID);
		}
		/*
		String urlPath = "";
		switch (Integer.valueOf(dicKind).intValue()){
			case 1:
				if (valDicCol == 1){//值对应字典列标识
					urlPath += "sysmng.report.do?subSys=sysmng&repID=7&isShowCnd=0&cnd_SUBSYS="+subSys+"&cnd_DICGRPID="+dicGrpID;
				}else if(valDicCol == 2){//值对应字典列描述
					urlPath += "sysmng.report.do?subSys=sysmng&repID=7&isShowCnd=0&cnd_SUBSYS="+subSys+"&cnd_DICGRPID="+dicGrpID;
				}
				break;
		}
		MvcActionAdmin mvcActionAdmin = new MvcActionAdmin(request);
		MvcAction mvcAction = mvcActionAdmin.findMvcAction(urlPath);
		String pageUrl = mvcAction.getUrlPath();
		try {
			pageUrl = request.getContextPath()+pageUrl +"?funcUrl="+URLEncoder.encode(urlPath, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		*/
		String urlPath = request.getContextPath();
		switch (Integer.valueOf(dicKind).intValue()){
			case 1:
				if (valDicCol == 1){//值对应字典列标识
					urlPath += "/page/";
				}else if(valDicCol == 2){//值对应字典列描述
					urlPath += "/sysmng.report.do?subSys=sysmng&repID=7&isShowCnd=0&cnd_SUBSYS="+subSys+"&cnd_DICGRPID="+dicGrpID;
				}
				break;
		}
		ActionResult ActionResult = new ActionResult();
		ActionResult.setUrlPath(urlPath);
		ActionResult.setReturnType(1);
		return ActionResult;
	}

}
